﻿package {

	class Node {
		
		public var in0:Number = 0;
		public var in1:Number = 0;
		public var in2:Number = 0;
		public var in3:Number = 0;
		public var out0:Number = 0;
		public var out1:Number = 0;
		public var out2:Number = 0;
		public var out3:Number = 0;
		public var inSum:Number = 0;
		
		private var m_oLeftNode:Node;
		private var m_oUpNode:Node;
		private var m_oRightNode:Node;
		private var m_oBottomNode:Node;
		
		
		function Node() {
		}
		
		
		function calcOut():void {
			inSum = (in0 + in1 + in2 + in3)*0.5;
			out0 = inSum - in0;
			out1 = inSum - in1;
			out2 = inSum - in2;
			out3 = inSum - in3;
		}
		
		
		function calcOutRefl():void {
			inSum = (in0 + in1 + in2 + in3)*0.5;
			out0 = 0.5*in0;
			out1 = 0.5*in1;
			out2 = 0.5*in2;
			out3 = 0.5*in3;
		}
		
		
		function calcIn():void {
			in0 = m_oUpNode.out3;
			in1 = m_oRightNode.out2;
			in2 = m_oLeftNode.out1;
			in3 = m_oBottomNode.out0;
		}

		
		function setNeighbours(oUpNode:Node, oBottomNode:Node, oLeftNode:Node, oRightNode:Node):void {
			m_oLeftNode = oLeftNode;
			m_oUpNode = oUpNode;
			m_oRightNode = oRightNode;
			m_oBottomNode = oBottomNode;
		}
		
	}
	
}